package it.unibz.ti2.internetPizzeria.servlets;

import it.unibz.ti2.internetPizzeria.utils.ServletUtil;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Removes userInfo session attribute in order to log user off
 */
public class Logout extends HttpServlet{

	private static final long serialVersionUID = -2463070557580463159L;

	protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
		this.doPost(arg0, arg1);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.getSession().removeAttribute("userInfo");
		ServletUtil.redirect(request, response, "/");
	}
}
